import SwiftUI
import AppKit

struct GameCellView: View {
    let cell: Cell
    let coordinate: Coordinate
    let viewModel: GameViewModel
    let size: CGFloat  
    
    var body: some View {
        CellView(
            cell: cell,
            size: size,
            onTap: {
                // 检查是否是右键点击或 Control+左键点击
                if let event = NSApp.currentEvent,
                   (event.type == .rightMouseDown || event.modifierFlags.contains(.control)) {
                    NSHapticFeedbackManager.defaultPerformer.perform(.levelChange, performanceTime: .now)
                    viewModel.toggleFlag(at: coordinate)
                } else {
                    viewModel.revealCell(at: coordinate)
                }
            },
            onLongPress: {
                NSHapticFeedbackManager.defaultPerformer.perform(.levelChange, performanceTime: .default)
                viewModel.toggleFlag(at: coordinate)
            }
        )
        .contentShape(Rectangle())
        // 禁用默认的上下文菜单
        .contextMenu(ContextMenu(menuItems: { }))
    }
} 
